package com.ts.animal.service.impl;

import com.ts.animal.dao.RfidSyncOriginalDataDao;
import com.ts.animal.domain.RfidSyncOriginalDataDO;
import com.ts.animal.service.RfidSyncOriginalDataService;
import com.ts.common.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class RfidSyncOriginalDataServiceImpl implements RfidSyncOriginalDataService {
    @Autowired
    private RfidSyncOriginalDataDao rfidSyncOriginalDataDao;

    @Override
    public RfidSyncOriginalDataDO get(Integer id) {
        return rfidSyncOriginalDataDao.get(id);
    }

    @Override
    public List<RfidSyncOriginalDataDO> list(Map<String, Object> map) {
        return rfidSyncOriginalDataDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return rfidSyncOriginalDataDao.count(map);
    }

    @Override
    public int save(Result result, RfidSyncOriginalDataDO rfidSyncOriginalData) {
        int ret = rfidSyncOriginalDataDao.save(rfidSyncOriginalData);
        if (ret == 0) {
            result.set(Result.FAIL, "保存失败", null);
        }
        return ret;


    }

    @Override
    public int update(Result result, RfidSyncOriginalDataDO rfidSyncOriginalData) {
        int ret = rfidSyncOriginalDataDao.update(rfidSyncOriginalData);
        if (ret == 0) {
            result.set(Result.FAIL, "更新失败", null);
        }
        return ret;
    }

    @Override
    public int remove(Result result, Integer id) {
        int ret = rfidSyncOriginalDataDao.remove(id);
        if (ret == 0) {
            result.set(Result.FAIL, "删除失败", null);
        }
        return ret;
    }

    @Override
    public int batchRemove(Result result, Integer[] ids) {
        int ret = rfidSyncOriginalDataDao.batchRemove(ids);
        if (ret != ids.length) {
            result.set(Result.FAIL, "部分删除失败", null);
        }
        return ret;
    }

}
